#include<stdlib.h>
#include<stdio.h>
int TOTAL_STATION = 5;
int STRATEGY = 1;
int DISTANCE = 2;
void readfile(void);
//测试函数
int main (void)
{
/*	FILE *fp;//测试用例创建
	if((fp=fopen("dict.dic","w"))==NULL)
  {
    printf("ERROR in opening the \"dict.dic\"\n");
    exit(1);
  }
  fprintf(fp,"#*********\nSTRATEGY = SCAN\n#*******#\nDISTANCE = 5\nTOTAL_STATION = 10");
  if(fclose(fp)!=0)
  {
    printf("ERROR in closing the \"dict.dic\"\n");
    exit(2);
  }*/
  readfile();
  printf("%d\n%d\n%d\n",TOTAL_STATION,STRATEGY,DISTANCE);
}
void readfile(void)
{
	FILE *fp;
	//打开文本文件
	if((fp=fopen("dict.dic","r"))==NULL)
  {
    printf("ERROR in opening the \"dict.dic\"\n");
    exit(1);
  }
	char ch[20];
	//读取参数
    while(fgets(ch,30,fp))
	{
		if(ch[0]=='#')//消解注释
		{
			continue;
		}
		else if(ch[0]=='T')//读取TOTAL_STATION，若无则为初始定义，因为>1且<=10
		{
			if(ch[16] == '1')
			TOTAL_STATION = 10;
			else
			TOTAL_STATION = ch[16]-'0';
		}
//读取策略，1为FCFS（先来先服务，2为SSTF（最短寻找时间优先，3为SCAN（顺便服务）,若无则为初始定义
		else if(ch[0]=='S')
		{
			if(ch[13]=='F')
			STRATEGY = 1;
			else if(ch[13]=='T')
			STRATEGY = 2;
			else if(ch[13]=='A')
			STRATEGY = 3;
		}
//读取每站之间的距离，若无则为初始定义,>0且<6
		else if(ch[0]=='D')
		{
			DISTANCE = ch[11]-'0';
		}
	}
	//关闭文件
  if(fclose(fp)!=0)
  {
    printf("ERROR in closing the \"dict.dic\"\n");
    exit(2);
  }
}
